package com.fittinghome.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @description:消息队列配置
 * @package com.fittinghome.config
 * @who MiaoMiao "Sprout" BI
 * @date 2021-04-13 16:20:34
 */
@Configuration
public class MqConfig {

    @Bean
    public TopicExchange exchangeNet(){
        TopicExchange directExchange=new TopicExchange("System.String, System.Private.CoreLib");
        return directExchange;
    }


    @Bean
    public Queue queueTencentYoushu() {
        Queue queue=new Queue(MqQueueNames.QUEUE_ORDER_CREATED);
        return queue;
    }

    /**
     * @Description: 绑定队列到路由键
     * @return: org.springframework.amqp.core.Binding
     * @Author: MiaoMiao "Sprout" BI
     * @Date: 2021-49-13 16:49
     */
    @Bean
    public Binding bindQueuewithOrderCreated(){
        Binding binding= BindingBuilder.bind(queueTencentYoushu()).to(exchangeNet()).with(MqEventNames.ORDER_CREATED);
        return binding;
    }
}
